<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../jquery.min.js"></script>
  </head>

  <body>
    <button class="btnGet">GET请求</button>
    <button class="btnPost">POST请求</button>
    <button class="btnDel">DELET请求</button>
    <button class="btnPut">PUT请求</button>
    <button class="btnJsonp">JSONP请求</button>

    <script>
      $(() => {
          $('.btnGet').click(() => {
                  $.ajax({
                      url: 'http://localhost:8080/home',
                      data: {
                          name: 'get'
                      },
                      success: (res) => {
                          console.log(res)
                      }
                  })
              })

              $('.btnPost').click(() => {
                  $.ajax({
                      url: 'http://localhost:8080/add',
                      type: "post",
                      data: {
                          name: 'post'
                      },
                      success: (res) => {
                          console.log(res)
                      }
                  })
              })

              $('.btnDel').click(() => {
                  $.ajax({
                      url: 'http://localhost:8080/delete',
                      type: "delete",
                      data: {
                          name: 'delete'
                      },
                      success: (res) => {
                          console.log(res)
                      }
                  })
              })

              $('.btnPut').click(() => {
                  $.ajax({
                      url: 'http://localhost:8080/put',
                      type: "put",
                      data: {
                          name: 'put'
                      },
                      success: (res) => {
                          console.log(res)
                      }
                  })
              })

              $('.btnJsonp').click(() => {
                  $.ajax({
                      method:'get',
                      url: 'http://localhost:8080/jsonp',
                      dataType:'jsonp',
                      success: (res) => {
                          console.log(res)
                      }
                  })
              })

            })





    </script>
  </body>
</html>
